<template>
	<div class="cspw">
		<div class="logo-img">
			<img src="../img-login/logo@3x.png"/>
		</div>
		<ul class="login-from">
			<li :class="{'active':pw1show}"><span><img src="../img-login/icon_key_dis@3x.png"/></span><span><img src="../img-login/icon_key_sel@3x.png"/></span><input type="password" name="" id="cspw" value="" placeholder="请输入新密码" v-model="cspw" @focus="pw1show=!pw1show" @blur="pw1show=!pw1show"/><span><img src="../img-login/icon_close@3x.png" @click="qingchu('first')" v-show="cspw"/></span></li>
			<li :class="{'active':pw2show}"><span><img src="../img-login/icon_re_dis@3x.png"/></span><span><img src="../img-login/icon_re_sel@3x.png"/></span><input type="password" name="" id="cspw1" value="" placeholder="请重复新密码" v-model="cspw1" @focus="pw2show=!pw2show" @blur="pw2show=!pw2show"/><span><img src="../img-login/icon_close@3x.png" @click="qingchu('tow')" v-show="cspw1"/></span></li>
		</ul>
		<p class="qrxgpw" @click="qrxg()">确认</p>
	</div>
</template>

<script>
	import cspwCss from "../css/cpw.css"
	
	var furl = 'http://www.ntyouxuan.com/';
	export default{
		name:"cspw",
		data(){
			return{
				cspw:"",
				cspw1:"",
				userTel:"",
				userYzm:"",
				pw1show:false,
				pw2show:false
			}
		},
		created:function(){
			this.userTel=localStorage.getItem("nt-tel");
			this.userYzm=localStorage.getItem("nt-ym");
			localStorage.removeItem("nt-ym");
			console.log(this.userTel);
		},
		methods:{
			qingchu:function(str){
				if(str=="first"){
					this.cspw="";
				}
				if(str=="tow"){
					this.cspw1="";
				}
			},
			qrxg:function(){
				console.log(this.userTel);
				var self=this;
				if(this.cspw===this.cspw1&&this.cspw){
					$.ajax({
						type:"post",
						url:furl+"index.php?app=ajax&act=set_password",
						data:{"phone_mob":self.userTel,"new_password":self.cspw,"confirm_password":self.cspw1,"confirm_code":self.userYzm},
						dataType:"json",
						success:function(res){
							history.go(-2);
						}
					});
				}else{
					layer.open({
						content: '两次密码不一样',
						skin: 'msg',
						time: 3 //3秒后自动关闭
					});
					console.log("两次密码不一样")
				}
			}
		}
	}
</script>

<style>
</style>